#include "Comm.hpp"
#include "Fifo.hpp"
#include <unistd.h>

int main()
{
    key_t key = GetShmKey();
    cout << "key:" << ToHex(key) << endl;

    int shmid = CreateShm(key, defaultsize);
    cout << "shmid:" << shmid << endl;

    char *addr = (char *)ShmAttach(shmid);
    cout << "Attach shm success, addr: " << ToHex((uint64_t)addr) << endl;
    Fifo fifo;
    Sync syn;
    syn.OpenRead();
    cout<<"准备好了"<<endl;
    while(true)
    {
        if (!syn.Wait())
            break;
        cout << "shm content:" << addr << endl;
    }
    ShmDetach(addr);
    cout << "Detach shm success, addr: " << ToHex((uint64_t)addr) << endl;
    DeleteShm(shmid);
    return 0;
}